/**
 * Created by Administrator on 2015/1/25.
 */
var utils = require('./utils');
var commands = new Array();

exports.allCommand = function () {
    return utils.processEjsTemplate("help", {commands: commands})
};

exports.execute = function (text) {
    for (var i = 0; i < commands.length; i++) {
        var command = commands[i];
        if (command.text.indexOf(text) == 0) {
            var check = command.check(text);
            if (check == 0) {
                return command.callback();
            } else {
                return check;
            }
        }
    }
    return this.allCommand();
}

exports.register = function(command){
    commands.push(command);
}

var checkCommand = function(command){

}